#include "SmartCar.h"
#include "Student.h"
#include "CarAssignment.h"
#include <iostream>
#include <vector>
using namespace std;

void showMenu() {
    cout << "====================" << endl;
    cout << "1. 数据录入" << endl;
    cout << "2. 展示数据" << endl;
    cout << "3. 退出程序" << endl;
    cout << "====================" << endl;
}

int main() {
    vector<CarAssignment> assignments;
    int choice;

    while (true) {
        showMenu();
        cout << "请选择操作: ";
        cin >> choice;

        switch (choice) {
            case 1: {
                // 数据录入
                assignments.clear();  // 清空当前的输入数据
                for (int i = 1; i <= 10; ++i) {
                    SmartCar car = inputCar(i);
                    Student student = inputStudent();
                    assignments.push_back({car, student});
                }
                // 保存信息到文件
                saveToFile(assignments);

                // 立即展示数据
                displayFromFile();
                break;
            }
            case 2: {
                // 展示数据
                displayFromFile();
                break;
            }
            case 3: {
                // 退出程序
                cout << "退出程序" << endl;
                return 0;
            }
            default: {
                cout << "无效的选择，请重新输入。" << endl;
                break;
            }
        }
    }

    return 0;
}
